<template>
  <div class="app-container">
    <div class="head">
      <img src="@/assets/img/Layout/position.png" />
      <p class="see-block">公司配置列表</p>
    </div>
    <div class="view-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true">
        <el-form-item label="公司名称" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入公司名称检索"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" class="list-search btn-success" color="#5ED4D4">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" class="list-search">重置</el-button>
        </el-form-item>
      </el-form>
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            class="btn-success"
            type="primary"
            icon="el-icon-plus"
            size="mini"
            @click="add()"
            v-hasPermi="['system:electronicAntiCompanyConfiguration:insert']"
          >新建</el-button>
        </el-col>
      </el-row>
      <el-table v-loading="loading" :data="list" @row-click="handleView" border>
        <el-table-column label="序号" type="index" align="center" width="50">
           <template slot-scope="scope">
            <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column label="公司logo" align="center" prop="logo">
          <template slot-scope="scope">
            <img v-if="scope.row.logo" :src="scope.row.logo" width="50" height="50" />
          </template>
        </el-table-column>
        <el-table-column label="公司名称" align="center" prop="name" :show-overflow-tooltip="true" />
        <el-table-column label="生产商" align="center" prop="manufacturer" :show-overflow-tooltip="true" />
        <el-table-column label="委托方" align="center" prop="client" :show-overflow-tooltip="true" />
        <el-table-column label="公众号二维码地址" align="center" prop="officialAccount" :show-overflow-tooltip="true" />
        <el-table-column label="跳转地址" align="center" prop="attachJumpLink" :show-overflow-tooltip="true" />
        <el-table-column label="扫码次数限制" align="center" prop="scanCodeTimes" :show-overflow-tooltip="true" />
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click.native.stop="edit(scope.row)"
              v-hasPermi="['system:electronicAntiCompanyConfiguration:update']"
            >编辑</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click.native.stop="handleDelete(scope.row)"
              v-hasPermi="['system:electronicAntiCompanyConfiguration:deleteById']"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>
  </div>
</template>

<script>
import { antiCodeCompanyConfigList, antiCodeCompanyConfigDelete } from "@/api/system/antiCode/antiCode"
export default {
  name: "list",
  data() {
    return {
      loading: true,
      total: 0,
      list: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: undefined
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 获取列表
    getList() {
      this.loading = true
      antiCodeCompanyConfigList(this.addDateRange(this.queryParams)).then(res => {
          this.list = res.rows
          this.total = res.total
          this.loading = false
      })
    },
    // 搜索按钮
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    // 重置按钮
    resetQuery() {
      this.resetForm("queryForm")
      this.handleQuery()
    },
    // 新建
    add(){
      this.$router.push({path:"/antiCode/corporation/add"})
    },
    // 编辑
    edit(row){
      this.$router.push({path:"/antiCode/corporation/edit", query:{id: row.id}})
    },
    // 查看详情
    handleView(row) {
      this.$router.push({path:"/antiCode/corporation/detail", query:{id: row.id}})
    },
    // 删除
    handleDelete(row){
      this.$modal.confirm('是否确认删除？').then(() => {
        antiCodeCompanyConfigDelete(row.id).then(() => {
          this.getList()
          this.$modal.msgSuccess("删除成功")
        })
      }).catch(() => {})
    },
  }
}
</script>